// mircoApp/tiktok_writeoff/record/record.js
const skinBehavior = require('../../../utils/themeSkin/skinBehavior');
const app = getApp();
Page({

  behaviors: [skinBehavior],
  /**
   * 页面的初始数据
   */
  data: {
    imgPath: app.globalData.imgPath,
    list: [],
    page: 1,
    total_page: 1,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData(1);
  },
  copybtn(e) {
    let inviteCode = e.target.dataset.code;
    wx.setClipboardData({
      data: inviteCode ? inviteCode : '',
    });
  },
  getData(page=1){
    app._getNetWork({
      url: app.getNetAddresss("plugin.tiktok-verify-ticket.api.record.index"),
      data: {
        page
      },
      success: resdata => {
        let {
          result,
          msg,
          data
        } = resdata.data;
        if (result !== 1) {
          return app.tips(msg);
        }
        this.data.page = data.current_page;
        this.data.total_page = data.last_page;
        if(data.current_page==1){
          this.setData({list:data.data})
        }else{
          let list = this.data.list.concat(data.data);
          this.setData({list});
        }


      }
    })
  },

  goto(e){
    let item = e.currentTarget.dataset.item;
    wx.navigateTo({
      url:"/mircoApp/tiktok_writeoff/detail/detail?id="+item.id
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if(this.data.page>=this.data.total_page){
      return;
    }
    let page = this.data.page+1;
    this.getData(page);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})